package cn.itsource.org.service.impl;

import cn.itsource.org.domain.Employee;
import cn.itsource.org.mapper.EmployeeMapper;
import cn.itsource.org.service.IEmployeeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@Service
@Transactional(readOnly = true,propagation = Propagation.SUPPORTS)
public class EmployessServiceImplI implements IEmployeeService {

    /**
     * 注入mapper层
     *
     * @return
     */
    @Autowired
    public EmployeeMapper employeeMapper;


    @Override
    public List<Employee> fainAll() {
        return employeeMapper.selectAll();
    }

    @Override
    public Employee FainOne(Long id) {
        return employeeMapper.selectByPrimaryKey(id);
    }

    @Override
    public void save(Employee employee) {
        employeeMapper.insertSelective(employee);
    }

    @Override
    public void update(Employee employee) {
        employeeMapper.updateByPrimaryKeySelective(employee);
    }

    @Override
    public void delete(Long id) {
        employeeMapper.deleteByPrimaryKey(id);
    }

}
